package rabbitmq.Direct;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import rabbitmq.utils.MqUtil;

public class Consumer01 {

    private final static String queueName="direct_logs";

    public static void main(String[] args) throws Exception {
        MqUtil mqUtil=new MqUtil();
        Channel chananel = mqUtil.getChananel();
        chananel.exchangeDeclare(queueName, BuiltinExchangeType.DIRECT);

        String queue = chananel.queueDeclare().getQueue();
        System.out.println(queue);
        chananel.queueBind(queue,queueName,"error");
        DeliverCallback deliverCallback=(consumerTag,delivery)->{
            String message = new String(delivery.getBody());
            System.out.println("控制台打印接收到的消息"+message);

        };
        chananel.basicConsume(queue,true,deliverCallback,consurmerTag->{});
    }
}
